package org.example.mockito.service;

import java.util.ArrayList;
import java.util.List;

import org.example.mockito.dao.OrderDao;
import org.example.mockito.model.Order;
import org.example.mockito.model.OrderSummary;
import org.example.mockito.transformer.OrderToSummaryTransformer;

public class OrderServiceImpl implements OrderService {

	private OrderDao orderDao = null;
	private OrderToSummaryTransformer transformer = null;

	public OrderServiceImpl() {

	}

	@Override
	public List<OrderSummary> getOrderSummary(Long customerId) {

		List<OrderSummary> resultList = new ArrayList<OrderSummary>();

		List<Order> orderList = orderDao.findOrdersByCustomerId(customerId);
		for (Order order : orderList) {

			OrderSummary summary = transformer.transform(order);
			resultList.add(summary);
		}

		return resultList;
	}

	public OrderDao getOrderDao() {
		return orderDao;
	}

	public void setOrderDao(OrderDao orderDao) {
		this.orderDao = orderDao;
	}

	public OrderToSummaryTransformer getTransformer() {
		return transformer;
	}

	public void setTransformer(OrderToSummaryTransformer transformer) {
		this.transformer = transformer;
	}

}
